package com.sl.biz.modular.process.controller;

import com.sl.biz.modular.process.controller.response.ProcessVersionVO;
import com.sl.biz.modular.process.dao.domain.dto.ProcessVersionDTO;
import com.sl.biz.modular.process.dao.domain.entity.ProcessVersionDO;
import com.sl.biz.modular.process.service.ProcessVersionBizService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/process/version")
@RequiredArgsConstructor
public class ProcessVersionController {
    private final ProcessVersionBizService versionBizService;

    @PostMapping("/save")
    public String save(@RequestBody @Validated ProcessVersionDO addRequest) {
        return versionBizService.save(addRequest);
    }

    @PostMapping("/get_by_process_and_version")
    public ProcessVersionDTO getByProcessIdAndVersion(@RequestBody @Validated ProcessVersionDO addRequest) {
        return versionBizService.getByProcessIdAndVersion(addRequest);
    }


    @PostMapping("/get_by_id")
    public ProcessVersionDTO getById(@RequestBody @Validated ProcessVersionDO addRequest) {
        return versionBizService.getById(addRequest);
    }

    @PostMapping("/list")
    public List<ProcessVersionVO> list(@RequestBody ProcessVersionDO processVersionDO) {
        return versionBizService.list(processVersionDO);
    }

    @PostMapping("/remove_by_id")
    public Boolean removeById(@RequestBody @Validated ProcessVersionDO removeByIdRequest) {
        return versionBizService.removeById(removeByIdRequest);
    }

    @PostMapping("/set_status_flag")
    public Boolean setStatusFlag(@RequestBody @Validated ProcessVersionDO assertUserUse) {
        return versionBizService.setStatusFlag(assertUserUse);
    }



    @PostMapping("/set_latest_flag")
    public Boolean setLatestFlag(@RequestBody @Validated ProcessVersionDO assertUserUse) {
        return versionBizService.setLatestFlag(assertUserUse);
    }
}
